﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BookStore.Data;
using BookStore.Common;
using BookStore.Bussiness;

namespace BookStore.admin
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            adminController ad = new adminController();

            adminInfo adinfo = new adminInfo();
            adinfo.username = txtusername.Text.Trim();
            adinfo.password = encryption.toMD5( txtpassword.Text.Trim());
           // adinfo.password =  txtpassword.Text.Trim();
            if (ad.CheckUser(adinfo))
              {
                  Session["Administrator"] = adinfo.username.ToString();
                  Session["Decen"] = adminService.checkDecen(Session["Administrator"].ToString());
                  if (txtusername.Text != "")
                  {
                     
                  }
                  Response.Redirect("Default.aspx");
              }
              else
              {
                  Response.Write("<script> window.alert('NOT! LOGIN SUCCESS')</script>");
                  txtpassword.Text = "";
                  txtusername.Text = "";
                  txtusername.Focus();
              }  
       }
    }

}